package com.example.dessert.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.dessert.dao.UserMapper;
import com.example.dessert.entity.User;
import com.example.dessert.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public User accountQueryUser(String account) {

        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("account",account);
        return userMapper.selectOne(wrapper);

    }


    @Override
    public User idQueryUser(Long id) {

        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("id",id);
        return userMapper.selectOne(wrapper);

    }


    @Override
    public Long storeUser(User user) {

        userMapper.insert(user);
        return  user.getId();

    }

    @Override
    public int saveUser(User user) {

        int result = userMapper.updateById(user);
        return  result;

    }


}
